package com.qs.controller;


import com.qs.model.vo.CategoryGoodsVo;
import com.qs.response.Response;
import com.qs.service.ICategoryService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 分类管理表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-04-02
 */
@Slf4j
@Validated
@CrossOrigin
@RestController
@RequiredArgsConstructor
@RequestMapping("/category")
public class CategoryController {

    private final ICategoryService categoryService;

    /**
     * 根据分类名获取商品数据
     * @param category
     * @return
     */
    @GetMapping("/name/{category}")
    public Response getGoodsWithCategory(@PathVariable("category") String category){
        log.info("获取分类：{}下的商品数据请求....", category);
        List<CategoryGoodsVo> list = categoryService.getGoodsWithCategory(category);
        log.info("获取分类：{}下的商品数据成功", category);
        return Response.success(list);
    }
}
